# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=tpcat
pkgver=latest
pkgrel=10
pkgdesc='Tool based upon pcapdiff by the EFF.'
groups=('blackarch' 'blackarch-misc')
arch=('any')
url='http://sourceforge.net/projects/tpcat/'
depends=('python2' 'wxpython' 'python2-pcapy')
license=('GPL')
source=('http://downloads.sourceforge.net/tpcat/TPCAT.py'
        'http://downloads.sourceforge.net/tpcat/tpcat.zip')
sha512sums=('8a7fdf58ad4099a7a15e42cb53d87946453a003865a4cd57cb87d08ce48e2f24e4e0e68968b59e107db551f3d1ad4668ae0bde3b9c36bb0346268aaed681b74b'
            'a2ed1b92c7cdd75c5727ba34a5aaada8c9569b8162a487165ff5097f8bce1da696e6f5b164a225f7d3f502e4772bb63f871f163ea93c6c33099e3537a3851275')

prepare() {
  grep -iRl 'python' "$srcdir" |
  xargs sed -i 's|#!.*/usr/bin/python|#!/usr/bin/python2|;s|#!.*/usr/bin/env python$|#!/usr/bin/env python2|'
}

package() {
  install -dm 755 "$pkgdir/usr/bin"

  install -Dm 755 TPCAT.py "$pkgdir/usr/share/$pkgname/$pkgname.py"
  install -Dm 644 "$pkgname/firewall.ico" \
    "$pkgdir/usr/share/$pkgname/firewall.ico"
  install -Dm 644 "$pkgname/Readme.txt" \
    "$pkgdir/usr/share/doc/$pkgname/Readme.txt"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python2 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

